package com.squirrel.common.controller;

import com.squirrel.common.exception.MyAuthenticationException;
import com.squirrel.common.response.code.CodeEnum;
import io.swagger.annotations.Api;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;

/**
 * @Description @RestControllerAdvice无法处理Filter抛出的异常，使用ErrorControllerImpl进行处理
 * @Author 关远键
 * @Version v1.0.0
 * @Date 2021/12/15 16:15
 */
@Controller
@Api(tags = "错误控制器")
public class ErrorControllerImpl implements ErrorController {

    @RequestMapping("/error")
    public void handleError(HttpServletRequest request) {
        System.out.println("执行了handleError=====>" + request);
        throw new MyAuthenticationException(CodeEnum.NO_AUTHORITY);
    }

}
